PHP beginner | 
                 | 
                
				
				Ik heb een vorige | volgende systeem maar er zit iets fout. Want ik heb in de config.php $ImaxItems op 5 staan. Dus als ik dan 5 nieuwsberichten gepost zou hebben dan zou die volgende moeten geven maar dat doet tie nu niet. Hij geeft geen vorige volgende aan:  
 
Dit is het script:  
    
    
        
            
                
<?php     
    include ('config.php');    
    $sNieuws = "SELECT * FROM nieuws ORDER BY id DESC"; 
    $iNieuwsItems = mysql_num_rows(mysql_query($sNieuws)); 
    if ($iNieuwsItems < 1) { 
        echo '<div align="center">Er zijn nog geen nieuwsberichten</div>'; 
    } 
    else { 
        $iNieuwsItems /= $iMaxItems; 
        $sUrl = '<a href="' . $_SERVER['REQUEST_URI'] . '?page=nieuws/nieuws&pagina='; 
        if (!isSet($iPagina)) { 
            $iPagina = 1; 
        } 
        $iVanaf = ($iPagina - 1) * $iMaxItems; 
        if ($iPagina > ceil($iNieuwsItems)) { 
            $iPagina = 1; 
        } 
        $aPagina = array(); 
        for ($i = 0; $i <= ceil($iNieuwsItems); $i++) { 
            if ($i == $iPagina) { 
                $aPagina[$i] = '<b>' . $i . '</b>'; 
            } 
            else { 
                $aPagina[$i] = '<a href="' . $_SERVER['REQUEST_URI'] . '?pagina=' . $i . '">' . $i . '</a>'; 
            } 
        } 
        $aPagina = implode(' | ', $aPagina); 
        if ($iPagina - 1) { 
            $sVorige = $sUrl . ($iPagina - 1) . '< Vorige</a>'; 
        } 
        else { 
            $sVorige = ''; 
        } 
             
        if ($iPagina - ceil($iNieuwsItems)) { 
            $sVolgende = $sUrl . ($iPagina + 1) . '> Volgende</a>'; 
        } 
             
        $sNavigatie = '<font face="verdana" size="-1" color="#000000">' . $sVorige . ' | ' . $sVolgende . '</font>'; 
        $rGeselecteerdNieuws = mysql_query("SELECT * FROM nieuws ORDER BY id DESC LIMIT $iVanaf, $iMaxItems"); 
        if (mysql_num_rows($rGeselecteerdNieuws) > 0) { 
            while ($rToonNieuws = mysql_fetch_assoc($rGeselecteerdNieuws)) { 
                $sBericht = htmlspecialchars($rToonNieuws['bericht']); 
                $sBericht = nl2br($sBericht); 
                $sBericht = wordwrap($sBericht, 60, "\n", 1); 
?> 
<div align="center"> 
    <table width="550" cellpadding="5" cellspacing="0" style="border-bottom: 1px solid #98CF12; border-top: 1px solid #98CF12; border-left: 1px solid #98CF12; border-right: 1px solid #98CF12;"> 
        <tr bgcolor="#FAFBF6"> 
            <td width="50%" valign='center' align="left"><b>Onderwerp:</b> 
                  
<?php echo $rToonNieuws['onderwerp']; ?> 
            </td> 
            <td width="50%" valign='center' align="left"><b> 
                Gepost op: 
            </b> 
              
<?php echo $rToonNieuws['datum']; ?> 
            </td> 
        </tr> 
        <tr bgcolor="#FAFBF6"> 
            <td colspan="3" align="left"> 
                <hr size="1" style="border-bottom: 1px solid #98CF12;"> 
<?php echo $sBericht; ?> 
                  </td> 
        </tr> 
    </table> 
</div> 
<br> 
<?php 
            } 
?> 
<div align="center" bgcolor="#000000"> 
<?php echo $sNavigatie; ?> 
</div> 
<?php 
        } 
        else { 
            echo 'Momenteel zijn er geen nieuwsberichten geplaatst.'; 
        } 
    } 
?> 
             
            <?php            include ('config.php');           $sNieuws = "SELECT * FROM nieuws ORDER BY id DESC";            if ($iNieuwsItems < 1) {          echo '<div align="center">Er zijn nog geen nieuwsberichten</div>';      }      else {          $iNieuwsItems /= $iMaxItems;            $sUrl = '<a href="' . $_SERVER['REQUEST_URI'] . '?page=nieuws/nieuws&pagina=';                $iPagina = 1;          }            $iVanaf = ($iPagina - 1) * $iMaxItems;            if ($iPagina > ceil($iNieuwsItems)) {              $iPagina = 1;          }              for ($i = 0; $i <= ceil($iNieuwsItems); $i++) {              if ($i == $iPagina) {                  $aPagina[$i] = '<b>' . $i . '</b>';              }              else {                  $aPagina[$i] = '<a href="' . $_SERVER['REQUEST_URI'] . '?pagina=' . $i . '">' . $i . '</a>';              }          }            $aPagina = implode(' | ', $aPagina);            if ($iPagina - 1) {              $sVorige = $sUrl . ($iPagina - 1) . '< Vorige</a>';          }          else {              $sVorige = '';          }            if ($iPagina - ceil($iNieuwsItems)) {              $sVolgende = $sUrl . ($iPagina + 1) . '> Volgende</a>';          }            $sNavigatie = '<font face="verdana" size="-1" color="#000000">' . $sVorige . ' | ' . $sVolgende . '</font>';            $rGeselecteerdNieuws = mysql_query("SELECT * FROM nieuws ORDER BY id DESC LIMIT $iVanaf, $iMaxItems");                      $sBericht = nl2br($sBericht);                  $sBericht = wordwrap($sBericht, 60, "\n", 1);    ?>    <div align="center">        <table width="550" cellpadding="5" cellspacing="0" style="border-bottom: 1px solid #98CF12; border-top: 1px solid #98CF12; border-left: 1px solid #98CF12; border-right: 1px solid #98CF12;">          <tr bgcolor="#FAFBF6">              <td width="50%" valign='center' align="left"><b>Onderwerp:</b>                     <?php echo $rToonNieuws['onderwerp']; ?>              </td>              <td width="50%" valign='center' align="left"><b>                  Gepost op:              </b>                 <?php echo $rToonNieuws['datum']; ?>              </td>          </tr>          <tr bgcolor="#FAFBF6">              <td colspan="3" align="left">                  <hr size="1" style="border-bottom: 1px solid #98CF12;">                    </td>          </tr>      </table>  </div>  <br>    <?php              }  ?>    <div align="center" bgcolor="#000000">  <?php echo $sNavigatie; ?>  </div>    <?php          }          else {              echo 'Momenteel zijn er geen nieuwsberichten geplaatst.';          }      }  ?> 
 
  
         
          
     
 				
				 |